Reimplemented moveAllowed variable and cleaned up functions.