Fixed missing package imports. Added support for weights