used a vector instead of png_malloc, minor cleanups also