Fixed a bug and replaced list concatenations with extensions.