Improve code readability; fixed bug in parsing part