Simplify some code, refactor and add support for parsing media queries