plug mem leaks in stock pixmap code, and refactor code a tiny little bit