fixes & refactor