small bug fixes; added global variable so it can be used in conjunction with sinatra app