Squashed some more bugs and added handling for empty elements.