done some variable handling
done some variable handling, added some useful comments
done some variable handling
minor changes, added relavant comments