Refactored swagger so that multiple instance can be intantiated

We have had the need to instantiate multiple instance of swagger in an application, particularly in a clustered environment. This change refactors the swagger module so that it can be instantiated. I tried to keep it backwards compatible.