All functions included. Needs testing