Made some bugfixes