Refactored away some particularly ugly code