simplify types
be explicit about functions
minor cleanups
couple bug fixes