More formatting and cast fixes