Done for the day.. Commented and cleaned the code a bit. The code still needs refactoring, but it seems to be funcitoning allright.. official tests still needed