Totally refactored (inside and outside).