Code clean up and simplification