More bug fixes

Most bugs should be fixed