Fixed the crash and added a couple of useful methods