firmware: code clean up