I've just changed 2-3 things because it doesn't want to compile with this source. But don't worry, the code seems to work, I've tested it myself. :P