Many fixes and additions to gear functions