more cleanup, added dynamic scheduling