Fix static keyword
Fix building with libpng
Minor refactor