Merged code + working weights computations.
Still very basic update.
Main loop is not finished: missing the call to the functions.