bug fixes to allow arbitrary elements