Bugfix

Lots of changes, detailed in each pull request
You're killin' me here buddy :D