bug fixes and other stuff
refactor