style changes and bug fixing