Refactor some local stuff