Minor bugfixes and commenting documentation