Abstractions and code clean up