Fixed bugs. Optimized some of the functions. Converted the sources to the new format.