Changed assignment (=) to equality(==) for BOOL. Various tweaks and cleanup