general library refactor. Introduced resultTo and argsTo functions