add frequency analysis features and fix several bugs