Cleanup and fix a little bug