Added functions for custom loop. Renamed classes into namespaces.