Fixed some namespace-related issues

Part of #169.
Fixed wrong entity references