Move size_autodetect to library
Add check for size_autodetect