refactor + fixes