Slight refactoring of checks and encoding methods