fixes, improvements, refactor