added necassary checks for reads and writes from a replica. Added more comments...