Bugfixes from testing with real world code