Basic validation

Some basic validation to avoid PHP-warnings due to uninitialized variables.