Added namespaces and code cleaning