small cleanup and initial support for subpalettes