Fork of @GulinSS's work.