fixes, refactor