Refactor

Move utility methods inside.