changed to handle module pattern and other things.