Please consult the Wiki for more information.
This is raw coding... no time to really optimize the code. Sorry