Added various features, see diff for details.