Code cleanup, fixed delta timing