Code improvements based on Bakual's feedback