Many bugfixes as suggested by first round of feedback.