code cleanup and transfer of parsecontext