cleaned code; fixed minor things