Implemented changes based on Mats suggestions