Misc refactor/cleanup of prototype code.