Written by Adrian Rossouw Thanks to Ratko Kovacina for the comments/debugging info