Change map format to png
Add NULL checks