bug fixes, refactoring
bug fixes, refactoring