Added check for trailing slash and debug option for cache