misc refactors
various upgrades, initial tests