Make elements immutable

Using ideas from http://stackoverflow.com/a/4828108/1079728

cc #300