Some cleanup of the code