Some minor code design improves