Some cleanup of code