Clean up and re-implement scratchpad