Added two command patterns. Made helper procedures private. Added explanatory comments.