Fixed various bugfixes