Re implemented changes from my fork into merged branch.

Signed-off-by: Lasse Moos <lasse@yourlocalstudio.dk>