Resolves #1 and partly #2