Dialyzer fixes and turn on warn_untyped_record & warnings_as_errors

This PR is not ready for merge, it needs someone who knows bitcask better to decide if the places marked with ```%% XXX``` are safe or unsafe ignores of the return value.