Fixed incorrect element insertion.

The inserted attributes and attribute values could sometimes be left not-findable by find() method and other methods that rely on it. The elements were still obtainable through iteration.
Added noexcept specifications. Simplified code in some cases.