Slightly cleaned-up code