Code polish

some local changes. for more info see forum pm.