Code and implementation cleanup