Code adjustments and improvemts for #151