Various bug fixes. Implements pass.