Misc cleanup/refactor of prototype