New thoroughly cleaned up version