Complete core rewrite

Condensed, cleaned and corrected the code responsible for monitoring and
controlling song state and beat events