Fixed engine debug and minor improvements