added some semicolons
refactoring + bugfixes