Reorganizing the code, simplified. Added global context processor #23.