Bugfixes, Code improvements