Adding s3 methods, fixing various bugs