high-res PNG output and some code cleanup
better error handling