General cleanup and fixes