Some refactoring/simplifying