Cleaning code, adding some functions.