simplified some macro usage, and added cast int -> bool