Updated with few comments etc.