Minor changes and refactor