fixes and small refactor