Added boolean variables.
Replaced all the 0 and 1 with $TRUE and $FALSE.