Properly fix #2216 by inlining the functions (and cleaning up the files)