Finished adding last missing code from the old version and started solving bugs from the conversion of the code