Added debug, cleaned up script