Cleaned up functions library (to be continued)