Did some minor code refactor