Fixed relative_path in rewrite check and SQL fixes for existing table data
Fixed SQL tables to better handle existing data