Added bug fixes matching Chaos' pull request comments