Fix bug, minor cleanup