Fixed lots of ugly code
Added support for file expiry