fix sorting defaults, minor code cleanup