Avoided null pointer exception, reformatted some stuff