Implemented optimal mask generation logic.
Removed obsolete psyco module.