Set content type to json for directories.
Fix bug when url had trailing slashes in it.
Better console logging.