bugfixes, formatting the code