better function file structure, general cleanup throughout library files