Imported changes from sourceforge: code cleaning, replacing loops
killing squads with die() methood.
commits r753-r754