First thing first... lets move all the flags to named constants... cause it's really becoming hard to follow