added serializable, fixed bugs