Minor change.
Code simplifications and bugfixes.