Implement quickEncode and helper functions