misc code formating, moved invert to ksession