I made some changes here, please pull them into main branch