Refactor some small issues