Multi Tenant Support

Added multi tenant support in some places. Will implement the rest
tomorrow.