Bugfixes and new featues

Lots and lots of changes (all for the better I hope)