some cleanups (ugh, old code)
merge with master