cleaning up and refactoring stuff - work in progress, not tested
cleaning up some obvious issues - still not tested (will do that when I'll get back home ;))
refactoring and cleanup