Error page handling (404 and 500) and bugs fixed