Fixed small bugs, replaced some filters with dict comprehension