refactor: cleanup some type casting