some fixes for ari's code.