added options, fixed bugs