Fixed issue #1

Fixed the issue with duplicates. Structure writer seems to work without
bugs now..