Slight refactoring, improved parsing