fixes, tweaks, refactoring