major bug fixes. Implemented new machine scheduler