Minor refactoring, magic numbers removed.