Command events (and some cleanup)