merged @savetheclocktower's amazing contribution