Added validity check and some getters and setters