Small bug fixes in main