Adding protection for null pointer exception because of no main system.