Various code clean up