More cleanup and abstraction