Fixed NullPointerException on first paint