Updated the functions file. Split the file into smaller components and also added proper post pagination using paginate_links() as explained by Morten here http://mor10.com/add-proper-pagination-default-wordpress-themes/