Added a debug mode as well as fix a few notices that appeared.