refactored to singletons
giant merge of singletons into code