More bug fixes in main