Some better comments and code consolidation