some crazy bugfixes