move all internal stuff in polymode-common.el and fix some compiler warnings