Fix dialyzer warnings and make all the records typed