Add AMD wrappers
Fix circular deps in router, clean up non-modular code