Added sweave compatibility, more comments, design changes