Removed unncessary if statement and refactored some array access to just use pointer syntax.