modernized aggpas, forked from http://sourceforge.net/projects/aggpasmod/