applied some fixes, cleanup learned from failed branch