Removed potential null pointer access, added tick counter