A few bugfixes from the port