added remove_top_rq function. moved ‘switch_processes’ to external function
general logic fixes