Fixes for a crash bug and an issue with the poll.