made many changes to deal with ugly urls